#ifndef YHAIDA_INETADDRESS_H
#define YHAIDA_INETADDRESS_H
#include <netinet/in.h>
#include <string>
#include <cassert>

#include <stdio.h>
#include <stdlib.h>  
#include <netdb.h>  
#include <string.h>
#include <sys/socket.h> 
#include <unistd.h>
#include <arpa/inet.h>

namespace yhaida
{
    class InetAddress
    {
    public:
        InetAddress() = default;
        ~InetAddress() = default;

        explicit InetAddress(uint16_t port);
        InetAddress(const std::string &ip, uint16_t port);
        InetAddress(const struct sockaddr_in &addr) : _addr(addr){};

        std::string toHostPort() const;
        sa_family_t family() const { return _addr.sin_family; }

        const struct sockaddr_in getSockAdrrInet() const { return _addr; }
        void setSockAddrInet(const struct sockaddr_in &addr) { _addr = addr; }

        static bool resolve(std::string hostname, InetAddress* out);

        uint32_t ipv4NetEndian() const;
    private:
        struct sockaddr_in _addr;
    };
}

#endif